class OrderExtra < ActiveRecord::Base  
  belongs_to            :order
  belongs_to            :order_option
  validates_presence_of :order
  validates_presence_of :order_option
  validates_presence_of :quantity, :if => :order_option_is_quantifiable?
  
  def cost
    self.order_option.cost
  end
  
  def description
    self.order_option.name
  end
protected
  def order_option_is_quantifiable?
    self.order_option.quantifiable?
  end
end
